package handler;

import jakarta.servlet.http.Cookie;
import mysql.Conn;

import java.sql.ResultSet;
import java.sql.SQLException;

//:TODO:获取授权码判断授权码是否有库存
public class Au {
    public static String getAu(String type) throws SQLException {
        Conn conn = new Conn();
        conn.getConn();
        String au = null;
        try {
           ResultSet resultSet = conn.selectau(type);
            if (resultSet.next()) {
               au = resultSet.getString("a_code");
               return au;
            }else {
                System.out.println("授权码已用尽,请等待后重新刷新页面");
                Manager.automatic(Manager.Default_Address());
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return "授权码获取失败";
    }


}
